//
//  AssociateProjsCell.swift
//  HuaYun
//
//  Created by enghou on 2018/11/28.
//  Copyright © 2018 xyxorigation. All rights reserved.
//

import UIKit

class AssociateProjsCell: UITableViewCell {

    @IBOutlet weak var nameLabel: UILabel!
    @IBOutlet weak var incomePredicateLabel: UILabel!
    @IBOutlet weak var incomeContractExecutelabel: UILabel!
    @IBOutlet weak var incomeExecuteLabel: UILabel!
    
    @IBOutlet weak var costPredicateLabel: UILabel!
    
    @IBOutlet weak var costContractExecuteLabel: UILabel!
    
    @IBOutlet weak var costExecuteRatioLabel: UILabel!

    private var _model: JSON?
    var model: JSON? {
        set{
            _model = newValue
//            "executeCost":0,                        //项目执行成本
//            "executeIncome":49900000,             //项目执行收入
//            "gsProjName":"2018年江西电力公司人资物力系统运维项目",
//            //项目名称
//            "id":"2c9eb0f26126f085016126f6a9210089",    //项目id
//            "orgCode":"x13x5x",                          //orgCode
//            "projBudget":95926100,                       //项目预计支出
//            "projEstimatedRevenue":140000000,            //项目预计收入
//            "executeIncome":95926100,               //项目执行收入
//            "executeCost":140000000                //项目执行成本
            nameLabel.text = _model?.contents?["gsProjName"]?.rawString()
            let incomepredicate = (_model?.contents?["projEstimatedRevenue"]?.int ?? 0) / 100
            incomePredicateLabel.text = String(incomepredicate).rmbformat
            let execute = (_model?.contents?["executeIncome"]?.int ?? 0) / 100
            incomeContractExecutelabel.text = String(execute).rmbformat
            let ratio = (_model?.contents?["incomeImplementationRate"]?.double ?? 0) * 100
            incomeExecuteLabel.text = String(format: "%.2f", ratio) + "%"
            
            let budget = (_model?.contents?["projBudget"]?.int ?? 0) / 100
            costPredicateLabel.text = String(budget).rmbformat
            let contractexecute = (_model?.contents?["executeCost"]?.int ?? 0) / 100
            costContractExecuteLabel.text = String(contractexecute).rmbformat
            
            let budgetratio = (_model?.contents?["costImplementationRate"]?.double ?? 0.0) * 100
            costExecuteRatioLabel.text = String(format: "%.2f", budgetratio) + "%"
        }
        get{
            return _model
        }
    }
    
    
    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }
    
}
